<template>
	<view class=" ">
	<view class="headerimg" v-if="top_list.length">
			<image :src="top_list[0].image" mode="widthFix"></image>
	</view>
	<view class="gridata align-center">
		<!-- 	<view v-if="wonav[0].status==1" @click="showpop" class="justify-center align-center flex-col ">
				<image src="/static/images/s1.png" mode=""></image>
				<text>抽奖专区</text>
			</view>
		
			
			
			
			<view v-if="wonav[0].status==1"  @click="showpop" class="justify-center align-center flex-col ">
				<image src="/static/images/s4.png" mode=""></image>
				<text>信息公示</text>
			</view> -->
			<block v-for="(i,n) in navs"  >
			<view class="justify-center align-center flex-col " @click="to(i)">
				<image :src="i.img" mode=""></image>
				<text>{{i.title}}</text>
			</view>
			</block>
			<view v-if="userRole.jiaose_id=='2'&&userRole.gys_status==2" class="justify-center align-center flex-col " @click="towxList">
				<image src="/static/images/s2.png" mode=""></image>
				<text>网红列表</text>
			</view>
			<view >
				<button class="justify-center align-center flex-col " style="line-height: 1;height: 100%;font-size: 26rpx;border: none;" open-type="contact"   @contact="contact">
				<image src="/static/images/s3.png" mode=""></image>
				<text>联系客服</text>
				</button>
			</view>
		<!-- 	<view  class="justify-center align-center flex-col " @click="toNotice">
				<image src="/static/images/xiaoxi.png" mode=""></image>
				<text>通知</text>
			</view> -->
	</view>
		
		<view class="" v-if="wonav[0].status==1" >
			<swiper class="swiper" circular indicator-active-color="#277CC0" :indicator-dots="false"
			     :autoplay="true" :interval="3000" :duration="500">
			     <swiper-item v-for="(i,n) in act_list" :key="n" >
			        <image :src="i.image" mode="" @click="to(i)"></image>
			     </swiper-item>
			 </swiper>
		</view>
		<custom-tab :value="0"></custom-tab>
	</view>
</template>

<script>
	import customTab from '../../components/customTab.vue';
	export default {
		components: {
			customTab
		},
		data() {
			return {
				menuTop: uni.getStorageSync('menuInfo').menuTop,
				menuHeight: uni.getStorageSync('menuInfo').menuHeight,
				dataList: [{},
					{}
				],
				top_list:[],
				act_list:[],
				userRole:{},
				wonav:[{
					status:'0'
				}],
				navs:[]

			}
		},
		onLoad() {
			this.$api.index().then(res=>{
				this.top_list=res.data.top_list
				this.act_list=res.data.act_list
			})
			this.$api.indexSwiper().then(res=>{})
			if(uni.getStorageSync('token')){
				this.$api.jiaoseinfo().then(res => {
					console.log(res)
					this.userRole = res.data
				})
			}
			this.$api.indexwonav().then(res=>{
				console.log(res)
				this.wonav=res.data
			})
			this.$api.indexshow().then(res=>{
				console.log(res)
				this.navs=res.data
			})
		},
		onShareAppMessage: function() {
			let that = this;
			wx.showShare1Menu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			});
			return {
				title: '',
				imageUrl: '',
				path: '/pages/tabbar/index'
			};
		},
		onShareTimeline: function() {
			let that = this;
			return {
				title: '',
				imageUrl: '',


			};
		},
		methods: {
			towxList(){
				
					uni.navigateTo({
						url:'/pages/applyPeople/index'
					})
			},
			toNotice(){
				
					uni.navigateTo({
						url:'/pages/notice/index'
					})
			},
			showpop(){
				uni.showModal({
					title:'提示',
					content:'功能正在开发中'
				})
			},
			contact(){
				
			},
				
			to(i){
				// if(!uni.getStorageSync('logintoken')){
				// 	uni.showModal({
				// 		title:'提示',
				// 		content:'请先注册并实名。成为会员才能够可以参与抽奖、以及奖品领取、使用'
				// 	})
				// 	return
				// }
				if(!i.url){
					uni.showModal({
						title:'提示',
						content:'功能正在开发中'
					})
				}else{
					if(i.status==0){
					return	uni.showModal({
							title:'提示',
							content:'功能正在开发中'
						})
					}
					uni.switchTab({
						url:i.url,
						fail:function(){
						uni.navigateTo({
							url:i.url
						})	
						}
					})
				}
			}
		},


	}
</script>
<style scoped lang="scss">
		
	.headerimg{
		image{
			width: 100%;
		}
	}
	.gridata{
		width: 706rpx;
		min-height: 170rpx;
		line-height: 1;
		padding: 0 20rpx;
		background: #FFFFFF;
		flex-wrap: wrap;
		border-radius: 12rpx;
		    margin: -180rpx auto 0;
		    position: relative;
			
		view{
			color: #383838;
			font-size: 26rpx;
			width: 25%;
			height: 170rpx;
			flex-shrink: 0;
			image{
				width: 60rpx;
				height: 60rpx;
				margin-bottom: 20rpx;
			}
		}
	}
	.swiper{
		width: 706rpx;
		height: 350rpx;
		margin: 24rpx auto;
		image{
			width: 706rpx;
			height: 350rpx;
			border-radius: 12rpx;
		}
	}
</style>